package org.chiv.gof.strategy;

public class StrategyModel {

    interface Strategy{
        void showStrategy();
    }

    static class StrategyA implements Strategy{
        public void showStrategy() {
            System.out.println("这里是策略A");
        }
    }

    class StrategyB implements Strategy{
        public void showStrategy() {
            System.out.println("这里是策略B");
        }
    }

    /**
     * 环境
     */
    static class Context {
        private Strategy strategy;

        public Context() {
        }

        public void setStrategy(Strategy strategy) {
            this.strategy = strategy;
        }
        public void showStrategy(){
            strategy.showStrategy();
        }

    }

    public static void main(String[] args) {
        Context context = new Context();
        StrategyA strategyA = new StrategyA();
        context.setStrategy(strategyA);
        context.showStrategy();
    }

}
